<?php
/**
 * Created by PhpStorm.
 * User: wodrow
 * Date: 10/2/18
 * Time: 6:33 PM
 */

namespace common\models\db;

use lhs\Yii2SaveRelationsBehavior\SaveRelationsBehavior;


/**
 * Class DocuCommentReply
 * @package common\models\db
 *
 * @property DocuComment $docuComment
 * @property User $createdBy
 * @property DocuCommentReply $forParent
 * @property DocuCommentReply[] $docuCommentReplies
 * @property User $atUser
 */
class DocuCommentReply extends \common\models\db\tables\DocuCommentReply
{
    const STATUS_DEFAULT = 10;

    public function behaviors()
    {
        return [
            'saveRelations' => [
                'class' => SaveRelationsBehavior::class,
                'relations' => [
                    'docuComment',
                ],
            ],
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getDocuComment()
    {
        return $this->hasOne(DocuComment::className(), ['id' => 'docu_comment_id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getCreatedBy()
    {
        return $this->hasOne(User::className(), ['id' => 'created_by']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getForParent()
    {
        return $this->hasOne(DocuCommentReply::className(), ['id' => 'for_parent_id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getDocuCommentReplies()
    {
        return $this->hasMany(DocuCommentReply::className(), ['for_parent_id' => 'id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getAtUser()
    {
        return $this->hasOne(User::className(), ['id' => 'at_user']);
    }
}